package com.persicadev.khayyam;

import java.util.List;
import java.util.Vector;

import android.util.Log;

public interface IPoemDb {

	public enum PoemType {robaei, ghazal};
	
	public class Poem {
		
		private Vector<Verse> poem = new Vector<IPoemDb.Verse>(2);
		private PoemType type;
		private int id = -1;
		
		public Poem(PoemType poemType) {
			type = poemType;
		}
		
		public Poem(Verse verses[], PoemType poemType) {
			type = poemType;
			for (Verse verse: verses) poem.add(verse);
		}
		
		public void addVerse(Verse verse) {
			poem.add(verse);
		}
		
		public int size() {
			return poem.size();
		}
		
		public Verse getVerse(int index) {
			return poem.get(index);
		}
		
		public PoemType getType() {
			return type;
		}

		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
		}
		
		public String getPoemBody()
		{
			
			return poem.get(0)+"";//+"\n"+poem.get(1)+"\n\n"+poem.get(2)+"\n"+poem.get(3);			
		}
		
	}
	
	public class Verse {
		
		private String parts[] = new String[2];
		
		public Verse() {
			parts[0] = "NOT SET";
			parts[1] = "NOT SET";
		}
		
		public Verse(String part1, String part2) {
			parts[0] = part1;
			parts[1] = part2;
		}
		
		public Verse(String parts[]) {
			parts[0] = new String(parts[0]);
			parts[1] = new String(parts[1]);
		}
		
		public void setPart1(String string) {
			parts[0] = string;
		}
		
		public void setPart2(String string) {
			parts[1] = string;
		}
		
		public String getPart1() {
			return new String(parts[0]);
		}
		
		public String getPart2() {
			return new String(parts[1]);
		}
		
		public String[] getParts() {
			return new String[] { getPart1(), getPart2() };
		}
		
	}
	
	/**
	 * 
	 * @return The total number of robaEs!
	 */
	public int totalPoems();
	
	/**
	 * Use Poem and Verse classes to create the poem.
	 * @param index
	 * @return The poem at the given index.
	 */
	public Poem getPoem(int id);

	
	/**
	 * 
	 * @param string
	 * @return The poem that contains the given String.
	 */
	
	
	public List<Poem> search(String string);

	public String getPoemBody(int position);
	
}
